﻿/// <reference path="../../Scripts/jquery-1.4.1-vsdoc.js" />
/// <reference path="../../Content/Scripts/Common.js" />

//这个属性由页面动态设置数据
var bigCates = [];
var error = '';
var selectedBigCateId = 0;
var selectedSubCateId = 0;

function returnBack() {
	window.location.href = "/MaterialManagement/ViewMaterialList";
}

function rebindSubCates() {
	var e = $("#BigCategoryId");
	var id = $selInt(e[0]);
	for (var i = 0; i < bigCates.length; i++) {
		var bigCate = bigCates[i];
		if (bigCate.value == id) {
			var subSelect = $("#CategoryId");
			$bindSelect(subSelect[0], bigCate.subCates);
			if (selectedSubCateId > 0) $selectValue(subSelect[0], selectedSubCateId);
			break;
		}
	}
}

//应用程序启动时绑定大小类别
$(function () {
	var e = $("#BigCategoryId");
	$bindSelect(e[0], bigCates);
	if (selectedBigCateId > 0) $selectValue(e[0], selectedBigCateId);

	rebindSubCates();
	e.change(rebindSubCates);

	if (error.length > 0) alert(error);
});